import 'node-assist'
import CommonUtil from 'js-common-modules/lib/node/utils/CommonUtil'
import BitcoinWalletHelper from 'js-common-modules/lib/node/helpers/bitcoin/BitcoinWalletHelper'

global['logger'] = console

const config = {
  version: 'testnet',
  mnemonic: 'my name is joy, human effort is the decisive factor.',
  password: 'test',
  index: 0 // m/0
}


CommonUtil.startAsyncMethod(async () => {
  const bitcoinWalletHelper = new BitcoinWalletHelper()
  const masterPair = bitcoinWalletHelper.getMasterPairByMnemonic(config['mnemonic'], config['password'], config['version'])
  const info = bitcoinWalletHelper.deriveAllByXprivIndex(masterPair['xpriv'], config['index'], config['version'])
  logger.error(info)
})

// 0
// { parentXpriv: 'tprv8ZgxMBicQKsPeHwyQy6ixa2PNBNWBc5rY8GenTT8WenmmEZZVnRgg99XgHke54nqfyiBdDBuCQZt99K4Z34RDBEzo7rbV1RH8SVeucijRFs',
//   index: 0,
//   xpriv: 'tprv8cimFiTmtTq64hd1K6fUBz7iQiGP5E18piCx49rHDdXujii1da8DFdF7P7xoUbnRJmnFm5NqyGsdSPj1XieQydJgFAcGnvXnPKWJbXfGNdd',
//   xpub: 'tpubD9QoQ8W22qWkxAeoCkL4bPmpyjnKEZC3Q1ojLftaduLJaCxnFxwoS7ryZG944zLBWobP2TsbPNaB8Hf4TXSUs1h3jZCHidfJdv2C97FThqM',
//   address: 'mpcFhXGhao3J7xaP1eCTKZP8t5vzN5jwND',
//   pubWif: '0368611bb1aff444be1c11717985d5bbdbe79542e1469b997b7a0d63ac1c761538',
//   wif: 'cUEHLwt7e7rXFoATPKyyWEGJv3BTznPSz79aFBWfyAHMzemCADCL' }

// 1
// { parentXpriv: 'tprv8ZgxMBicQKsPeHwyQy6ixa2PNBNWBc5rY8GenTT8WenmmEZZVnRgg99XgHke54nqfyiBdDBuCQZt99K4Z34RDBEzo7rbV1RH8SVeucijRFs',
//   index: 1,
//   xpriv: 'tprv8cimFiTmtTq67kjovTtG2sfym86Lwsgz3sHBtRdgiiswXcLBKXeibtHHa8muLpAuwUvVvP5ihRrJRXdE81yoVethEYZJ8DjwWDWuwHveGBh',
//   xpub: 'tpubD9QoQ8W22qWm1Dmbp7YrSHL6L9cH7CstdAsyAwfz8zgLN6awwvUJnNu9kHk5VPoFUszMtj13VZz51YJjUaziivjy8jgr6eE9UbN8VQopXnH',
//   address: 'n3chACpRvZHr5zvCLcxVPtguwGWSMHC4fk',
//   wif: 'cNba81BQx96AnCLhJMxYQvU63JhgyamCkSheDzuwiErX6mv2mGdg' }


